package com.itpan.Service.Impl;

import com.itpan.Entity.Employee;
import com.itpan.Entity.PurchaseOrder;
import com.itpan.Entity.StatsByT;
import com.itpan.Mapper.PurchaseOrderMapper;
import com.itpan.Service.PurchaseOrderService;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class PurchaseOrderServiceImpl implements PurchaseOrderService {
    @Autowired
    private PurchaseOrderMapper purchaseOrderMapper;

    @Override
    public List<PurchaseOrder> getall() {
        return purchaseOrderMapper.getAll();
    }

    @Override
    public List<PurchaseOrder> getallpage(Integer page, Integer pageSize) {
        RowBounds rowBounds = new RowBounds(page, pageSize);
        return purchaseOrderMapper.getAllPage(rowBounds);
    }

    @Override
    public List<PurchaseOrder> getByMutil(PurchaseOrder purchaseOrder) {
        return purchaseOrderMapper.getbyMutil(purchaseOrder);
    }

    @Override
    public PurchaseOrder getById(Long Id) {
        return purchaseOrderMapper.getById(Id);
    }

    @Override
    public void saveOne(PurchaseOrder purchaseOrder) {
        purchaseOrderMapper.addOne(purchaseOrder);
    }

    @Override
    public void saveAll(List<PurchaseOrder> list) {
        purchaseOrderMapper.addAll(list);
    }

    @Override
    public void update(PurchaseOrder purchaseOrder) {
        purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
    }

    @Override
    public void delete(Long Id) {
        purchaseOrderMapper.deleteById(Id);
    }

    @Override
    public List<StatsByT> getSumPriceOfEveryEmployee() {
        return purchaseOrderMapper.getSumPriceOfEveryEmployee();
    }

    @Override
    public List<StatsByT> getcounttimesofEmployee() {
        return purchaseOrderMapper.getcounttimeofemployee();
    }

    @Override
    public List<Employee> getbyempid(String id) {
        return purchaseOrderMapper.getbyempid(id);
    }

    @Override
    public List<StatsByT> gettotalof7() {
        return purchaseOrderMapper.gettotalof7();
    }

    @Override
    public List<PurchaseOrder> getOrdersWithinDateRange(LocalDateTime startDate, LocalDateTime endDate) {
        return purchaseOrderMapper.getPurchaseOrdersByDateRange(startDate,endDate);
    }
}
